<?xml version="1.0" ?>
<project xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">
	<property name="sign" value="false" overwrite="false" />
	<property name="key.file" value="${root.dir}/src/NH.Linq.snk" />
	<property name="lib.dir" value="lib" dynamic="true" />
	<property name="lib.family.dir" value="${path::combine(lib.dir, framework::get-family(framework::get-target-framework()))}" dynamic="true" />
	
	<property name="nant-version.current" value="${assemblyname::get-version(assembly::get-name(nant::get-assembly()))}" />
	<property name="nant-version.required" value="0.85.2478.0" /> <!-- Nant 0.85 release version -->
	<property name="nant-version.beta1_086" value="0.86.2898.0" /> <!-- Nant 0.86 Beta 1 -->
	<if test="${nant-version.current != nant-version.beta1_086 or framework::get-target-framework() != 'net-3.5'}">
		<property name="lib.framework.dir" value="${path::combine(lib.family.dir, version::to-string(framework::get-version(framework::get-target-framework())))}" dynamic="true" />
	</if>
	<if test="${nant-version.current == nant-version.beta1_086 and framework::get-target-framework() == 'net-3.5'}">
		<echo>Detected NAnt 0.86 Beta 1, consider upgrading to a newer version (a nightly build) when building for .NET 3.5</echo>
		<echo>The latest NAnt nightly can be downloaded from http://nant.sourceforge.net/nightly/latest/nant-bin.zip</echo>
		<property name="lib.framework.dir" value="${path::combine(lib.family.dir, string::substring(framework::get-target-framework(), 4, 3))}" dynamic="true" />
	</if>
	<property name="project.company" value="NHForge.org" />
	<property name="project.version" value="1.0.0.GA" overwrite="false" />
	<regex input="${project.version}" pattern="^(?'shortversion'\d+\.\d+)" />
	<property name="project.version.short" value="${shortversion}" />

	<!-- Compute and set project.version.numeric from project.version if it hasn't been set already -->
	<if test="${not property::exists('project.version.numeric')}">

		<script language="C#">
			<code><![CDATA[
				public const int BaseAlpha = 1000;
				public const int BaseBeta  = 2000;
				public const int BaseCR    = 3000;
				public const int BaseGA    = 4000;
				// SP is same as GA because GA has no number and SP's start with 1.
				public const int BaseSP    = 4000;

				public static void ScriptMain(Project project)
				{
					project.Properties["project.version.numeric"] = ToNumericVersion(
						project.Properties["project.version"]);
				}

				public static string ToNumericVersion(string version)
				{
					int qualifierStart = version.LastIndexOf('.') + 1;
					int qualifierNumberStart = version.IndexOfAny(
						"0123456789".ToCharArray(),
						qualifierStart);

					if (qualifierNumberStart < 0) qualifierNumberStart = version.Length;

					string qualifier = version.Substring(qualifierStart, qualifierNumberStart - qualifierStart);
					int qualifierNumber = qualifierNumberStart < version.Length
						? int.Parse(version.Substring(qualifierNumberStart))
						: 0;

					int revisionBase;

					switch (qualifier)
					{
						case "Alpha": revisionBase = BaseAlpha; break;
						case "Beta":  revisionBase = BaseBeta; break;
						case "CR":    revisionBase = BaseCR; break;
						case "GA":    revisionBase = BaseGA; break;
						case "SP":    revisionBase = BaseSP; break;

						default: throw new BuildException("Unknown version qualifier " + qualifier);
					}

					string revisionNumber = (revisionBase + qualifierNumber).ToString();

					return version.Substring(0, qualifierStart) + revisionNumber;
				}
			]]></code>
		</script>
	</if>
	
	
		<!-- debug|release -->
	<property name="build.defines" value="" />

	<!-- platform specific properties. These are the defaults -->
	<property name="current.build.defines" value="${build.defines}" />
	
		<target name="set-debug-project-configuration" description="Perform a 'debug' build">
		<property name="build.release" value="false" />
		<property name="build.debug" value="true" />
		<property name="build.name" value="NHibernate.Linq-${project.version}-${project.config}" />
	</target>
	
	<target name="set-release-project-configuration" description="Perform a 'release' build">
		<property name="build.release" value="true" />
		<property name="build.debug" value="false" />
		<property name="build.name" value="NHibernate.Linq-${project.version}" />
	</target>

	<target name="set-project-configuration">
		<property name="project.config" value="debug" overwrite="false" />
		<if test="${not(target::exists('set-' + project.config + '-project-configuration'))}">
			<fail message="Unknown configuration: '${project.config}'" />
		</if>

		<call target="set-${project.config}-project-configuration" />

		<property name="build.root.dir" value="${root.dir}/build/${build.name}" />
		<property name="build.dir" value="${build.root.dir}" />
		<property name="bin.dir" value="${build.dir}/bin/${nant.settings.currentframework}" />
		<property name="testresults.dir" 	value="${bin.dir}/test-results" />
		<property name="tools.dir" value="${root.dir}/Tools"/>
	</target>
	


	<target name="set-framework-configuration">
		<if test="${not(target::exists('set-'+framework::get-target-framework()+'-framework-configuration'))}">
			<fail message="The '${framework::get-target-framework()}' framework is not supported by this version of NHibernate." />
		</if>
		<call target="set-${framework::get-target-framework()}-framework-configuration" />
	</target>

	<target name="set-net-3.5-framework-configuration">
		<property name="nant.settings.currentframework" value="net-3.5" />
		<property name="current.build.defines" value="${build.defines}NET,NET_2_0,NET_3_5" />
		<!-- not using SDK_v2_0 because ndoc throws an exception -->
		<property name="link.sdkdoc.version" value="SDK_v1_1" />
		<!-- merge should work with 2.0 when compiling for 3.5 -->
		<property name="merge.targetplatform" value="v2" />
	</target>
	


	<target name="set-mono-3.5-framework-configuration">
		<property name="nant.settings.currentframework" value="mono-3.5" />
		<property name="current.build.defines" value="${build.defines}NET,NET_2_0,NET_3_5,MONO" />
		<!-- not using SDK_v2_0 because ndoc throws an exception -->
		<property name="link.sdkdoc.version" value="SDK_v1_1" />
		<!-- merge should work with 2.0 when compiling for 3.5 -->
		<property name="merge.targetplatform" value="v2" />
	</target>


	<target name="display-current-runtime">
		<echo message="" />
		<echo message="----------------------------------------------------------" />
		<echo message=" ${framework::get-description(framework::get-target-framework())}" />
		<echo message="----------------------------------------------------------" />
		<echo message="" />
		<echo message="framework : ${framework::get-target-framework()}" />
		<echo message="description : ${framework::get-description(framework::get-target-framework())}" />
		<echo message="sdk directory : ${framework::get-sdk-directory(framework::get-target-framework())}" />
		<echo message="framework directory : ${framework::get-framework-directory(framework::get-target-framework())}" />
		<echo message="assembly directory : ${framework::get-assembly-directory(framework::get-target-framework())}" />
		<echo message="runtime engine : ${framework::get-runtime-engine(framework::get-target-framework())}" />
		<echo message="" />
	</target>

	<target name="common.init"
		depends="set-framework-configuration set-project-configuration"
		description="Initializes build properties">

		<fileset id="project.sources" failonempty="true">
			<include name="**/*.cs" />
		</fileset>
		<resourcefileset id="project.resources" />
	</target>
</project>
	
	
	